<?php

namespace catchAdmin\basics\model;

use catchAdmin\basics\model\search\RouteSearch;
use catcher\base\CatchModel;
use think\facade\Db;

/**
 *
 * @property int $id
 * @property string $route_name
 * @property string $route_code
 * @property int $tenant_id
 * @property int $creator_id
 * @property int $created_at
 * @property int $updated_at
 * @property int $deleted_at
 */
class Route extends CatchModel
{
    use RouteSearch;
    
    public $field = [
        // ID
        'id',
        // 航线名称
        'route_name',
        // 航线编码（英文）
        'route_code',
        // 商户
        'tenant_id',
        // 创建人
        'creator_id',
        // 创建时间
        'created_at',
        // 更新时间
        'updated_at',
        // 删除时间
        'deleted_at',
    ];
    
    public $name = 'db_route';

    /**
     * 列表
     * @throws \think\db\exception\DbException
     * @return \think\Paginator
     */
    public function getList($tenant_id = 0)
    {
        $where = [];
        if($tenant_id != 0){
            $where[]=['tenant_id','=',$tenant_id];
        }
        return $this->catchSearch()
            ->order('id','desc')
            ->where($where)
            ->withoutField('tenant_id,creator_id,updated_at,deleted_at,created_at')
            ->paginate();
    }
}